using Godot;
using System.Collections.Generic;

public class HotBar : Control
{
    public List<Slot> slots = new List<Slot>();
    public Sprite Slotcurosr;
    public override void _Ready()
    {
        Slotcurosr = GetNode<Sprite>("Slotcurosr");
        for (int i = 1; i < 10; i++)
        {
            slots.Add(GetNode<Slot>($"Hotbar/{i}"));
        }
    }

    public override void _Process(float delta)
    {
        if (BlockWorld.player != null)
        {
            int x = -84 + BlockWorld.player.store.getIndex() * 21;
            Slotcurosr.Position = new Vector2(x, Slotcurosr.Position.y);
        }
    }
    //更新快捷栏
    public void Updata()
    {
        for (int i = 0; i < 9; i++)
        {
            ItemStack item = BlockWorld.player.store.GetItemStack(i);
            slots[i].SetItemStack(item);
        }
    }
}
